package com.yoomiito.app.ui.my.remain.deduct

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.BaseList
import com.yoomiito.app.model.my.DeductMoneyDetail
import com.yoomiito.app.net.YmApi

class DeductMoneyPresenter(appConfig: AppConfig) :BaseActPresenter<DeductMoneyActivity>(appConfig){

    fun getData(page:Int){
        YmApi.getYmService()
                .deductMoneyDetail(page)
                .compose(v.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object :ApiSubscriber<BaseList<DeductMoneyDetail>>(){
                    override fun onSuccess(t: BaseList<DeductMoneyDetail>?) {
                        v?.setData(t)
                    }

                    override fun onFail(error: ApiException?) {
                        v?.dismissLoading()
                    }
                })
    }
}